package com.bawei.user

import androidx.lifecycle.MutableLiveData
import com.bawei.base.bean.AddUserEntity
import com.bawei.base.bean.UserEntity
import com.bawei.base.mvvm.BaseViewModel
import com.bawei.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class UserViewModel @Inject constructor(var apiService: ApiService):BaseViewModel(){
    var userSuccess=MutableLiveData<MutableList<UserEntity>>()
    var addUserSuccess=MutableLiveData<UserEntity>()
    fun user(id:Int){
        httpRequest({apiService.userById(id)},{userSuccess.postValue(it)})
    }
    fun addUser(addUserEntity: AddUserEntity){
        httpRequest({apiService.addUserCheck(addUserEntity)},{addUserSuccess.postValue(it)})
    }
}